<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div></div>
    <script>
      var div = document.querySelector("div");
      function goTime(time) {
        var date = new Date();
        var dataTime = date.getTime(); // 到目前的时间戳
        var will = new Date(time);
        var willTime = will.getTime(); // 到输入的后的时间戳
        var times = (willTime - dataTime) / 1000; // 剩余总秒数
        var d = parseInt(times / 60 / 60 / 24)
          .toString()
          .padStart(2, "0"); //天
        var h = parseInt((times / 60 / 60) % 24)
          .toString()
          .padStart(2, "0"); // 时
        var f = parseInt((times / 60) % 60)
          .toString()
          .padStart(2, "0"); // 分
        var s = parseInt(times % 60)
          .toString()
          .padStart(2, "0"); // 秒
        var all = `${d}天${h}时${f}分${s}秒`;
        div.innerHTML = all;
      }
      goTime("2020-11-11 00:00:00");
      setInterval('goTime("2020-11-11 00:00:00")', 1000);
    </script>
  </body>
</html>
